package router

import (
	"goGin/middlewares"

	"github.com/garyburd/redigo/redis"
	"github.com/gin-gonic/gin"
	"gorm.io/gorm"
)

type Option func(*gin.Engine, *gorm.DB, redis.Conn)

var options = []Option{}

// 注册app的路由配置
func Include(opts ...Option) {
	options = append(options, opts...)
}

// 初始化
func Inits(c *gorm.DB, red redis.Conn) *gin.Engine {
	r := gin.New()
	r.Use(middlewares.Cors())
	r.Use(middlewares.Token())
	r.Static("/static", "./static")
	for _, opt := range options {
		opt(r, c, red)
	}
	return r
}
